import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rainflutter/Tools/gif.dart';
import 'package:rainflutter/Tools/gif/gif_demo.dart';
import 'package:rainflutter/Tools/gif/gif_progress.dart';

class GifTestPage extends StatefulWidget {
  @override
  _GifTestPageState createState() => _GifTestPageState();
}

class _GifTestPageState extends State<GifTestPage>
    with SingleTickerProviderStateMixin {
  GifController controller;

  @override
  void initState() {
    super.initState();
    controller = GifController(vsync: this);
    controller.addListener(() {
      setState(() {});
    });
  }

  Widget get initFloatingActionButton {
    return FloatingActionButton(
      backgroundColor: Colors.grey,
      elevation: 1,
      focusElevation: 1,
      onPressed: () {
        if (controller.isAnimating) {
          controller.stop();
        } else {
          controller.play();
        }
        setState(() {});
      },
      child: Icon(Icons.android),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: initFloatingActionButton,
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
      extendBody: true,
      body: Center(
          child: Container(
        width: 400,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  // CustomBezierWidget1(),
                  // WidgetCircleProgressWidget(),
                  Container(
                    width: 200,height:200,
                      color: Colors.white, child: CustomBezierWidget2(40)),

                  // Container(
                  //   width: 100,
                  //   height: 100,
                  //   child: ProgressManager(progress: 0.8)),
                ],
              ),
            ),
            Text(
              '总帧数：${controller.frames}\n'
              '当前帧数：${controller.frame}\n'
              '当前循环次数：${controller.playCount}\n',
              maxLines: 4,
              overflow: TextOverflow.ellipsis,
            ),
            // GifImage(
            //   controller: controller,
            //   image: AssetImage('assets/gif/carbon_bolang.gif'),
            // )
          ],
        ),
      )),
    );
  }
}
